package com.jus.player.config;

public enum HttpStatusEnum {

    OK(200, "OK", true),

    BAD_REQUEST(400, "Bad Request", false),
    UNAUTHORIZED(401, "Unauthorized", false),
    PAYMENT_REQUIRED(402, "Payment Required", false),
    FORBIDDEN(403, "Forbidden", false),
    NOT_FOUND(404, "Not Found", false),
    METHOD_NOT_ALLOWED(405, "Method Not Allowed", false),

    INTERNAL_SERVER_ERROR(500, "Internal Server Error", false),
    NOT_IMPLEMENTED(501, "Not Implemented", false),
    BAD_GATEWAY(502, "Bad Gateway", false),
    SERVICE_UNAVAILABLE(503, "Service Unavailable", false),
    GATEWAY_TIMEOUT(504, "Gateway Timeout", false),

    NONE(999, "Undefined Status", false);

    private final int value;
    private final String reason;
    private final boolean ok;

    HttpStatusEnum(int value, String reason, boolean ok) {
        this.value = value;
        this.reason = reason;
        this.ok = ok;
    }

    public static HttpStatusEnum getInstance(int value) {
        for (HttpStatusEnum e : HttpStatusEnum.values()) {
            if (e.getValue() == value) {
                return e;
            }
        }
        return NONE;
    }

    public boolean ok() {
        return ok;
    }
    public int getValue() {
        return this.value;
    }

    public String getReason() {
        return this.reason;
    }
}
